<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="com.informet.ipd.modelo.dao.ProgEstrDao" %>
<%@ page import="com.informet.ipd.modelo.vo.ProgEstrVO" %>
<%@ page import="com.informet.ipd.struts.form.ProgEstrForm" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.swing.JOptionPane"%>

<%@ taglib uri="/tags/c" prefix="c"%>

<%
        //JOptionPane.showMessageDialog(null, "id "+"o");
            StringBuffer cadenaSalida = new StringBuffer();
            List lista = null;

            int id = Integer.parseInt(request.getParameter("id"));
            ProgEstrDao supportFacade = new ProgEstrDao();
            ProgEstrForm form = new ProgEstrForm();

            try {


                String codTipCombo = request.getParameter("codTipCombo");
                //JOptionPane.showMessageDialog(null, "id "+id);
                ProgEstrVO vo;
                if (codTipCombo.equals("llenarComboOee") )
                {
                  //  JOptionPane.showMessageDialog(null, id);
                         
                        lista = supportFacade.getlistOEE(id);
                        form.setOEE(lista);

                        cadenaSalida.append("<table  width='100%' align='center' >");
                        cadenaSalida.append("   <tr> ");
                        cadenaSalida.append("       <td width='50%'align='right'>");
                        cadenaSalida.append("           OEE &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                        cadenaSalida.append("       </td>");
                        cadenaSalida.append("       <td >"); 

                        
                        cadenaSalida.append("           <select  name='codOee' id='codOee' onchange='buscarComboActividades()' >");
                        cadenaSalida.append("               <option value='-1'>[--Seleccionar Obj Especifico--]</option>");
                          // JOptionPane.showMessageDialog(null, "id "+id);
                                                                Iterator it = lista.iterator();
                                                                while (it.hasNext()) {
                                                                        vo = (ProgEstrVO) it.next();
                                                                        cadenaSalida.append("<option value='"+vo.getCOD_OEE()+"'>"+vo.getDESC_OEE()+"</option>");
                                                                }
                        cadenaSalida.append("           </select>");

                        cadenaSalida.append("         </td>");
                        cadenaSalida.append("   </tr>");


                        cadenaSalida.append("   <tr>");
                        cadenaSalida.append("       <td align='right'>");
                        cadenaSalida.append("           Actividades &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                        cadenaSalida.append("       </td>");



                      //  cadenaSalida.append("<div id=comboHijo>");
                        cadenaSalida.append("       <td >");
                        cadenaSalida.append("           <select  name='codActividad' id='codActividad' >");
                        cadenaSalida.append("               <option value='-1'>[--Seleccionar Actividades--]</option>");
                        cadenaSalida.append("           </select>");
                        cadenaSalida.append("       </td>");
                        cadenaSalida.append("   </tr>");
                        cadenaSalida.append(" </table>");

                       // cadenaSalida.append("</div");
                }
                else if (codTipCombo.equals("llenarComboAct"))
                {
                        int idOge = Integer.parseInt(request.getParameter("idOge"));
                        lista = supportFacade.getlistOEE(idOge);
                        form.setOEE(lista);

                        cadenaSalida.append("<table  width='100%' align='center' >");
                        cadenaSalida.append("   <tr> ");
                        cadenaSalida.append("       <td width='50%'align='right'>");
                        cadenaSalida.append("           OEE &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                        cadenaSalida.append("       </td>");
                        cadenaSalida.append("       <td >");


                        cadenaSalida.append("           <select  name='codObjEsp' id='codOee' onchange='buscarComboActividades()' >");
                        cadenaSalida.append("               <option value='-1'>[--Seleccionar Obj Especifico--]</option>");
                          // JOptionPane.showMessageDialog(null, "id "+id);
                                                                Iterator it = lista.iterator();
                                                                while (it.hasNext()) {
                                                                        vo = (ProgEstrVO) it.next();
                                                                        if(vo.getCOD_OEE()!=id)
                                                                            cadenaSalida.append("<option value='"+vo.getCOD_OEE()+"'>"+vo.getDESC_OEE()+"</option>");
                                                                        else
                                                                            cadenaSalida.append("<option selected value='"+vo.getCOD_OEE()+"'>"+vo.getDESC_OEE()+"</option>");
                                                                }
                        cadenaSalida.append("           </select>");

                        cadenaSalida.append("         </td>");
                        cadenaSalida.append("   </tr>");


                        cadenaSalida.append("   <tr>");
                        cadenaSalida.append("       <td align='right'>");
                        cadenaSalida.append("           Actividades &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                        cadenaSalida.append("       </td>");

                        lista = supportFacade.getlistActividades(id);

                      //  cadenaSalida.append("<div id=comboHijo>");
                        cadenaSalida.append("       <td >");
                        cadenaSalida.append("           <select  name='codActividad' id='codActividad' >");
                        cadenaSalida.append("               <option value='-1'>[--Seleccionar Actividades--]</option>");
                                                             it = lista.iterator();
                                                             while (it.hasNext())
                                                             {
                                                                 vo = (ProgEstrVO) it.next();
                                                                 cadenaSalida.append("<option value='"+vo.getCOD_ACTIVIDAD()+"'>"+vo.getDESC_ACTIVIDA()+"</option>");
                                                             }


                        cadenaSalida.append("           </select>");
                        cadenaSalida.append("       </td>");
                        cadenaSalida.append("   </tr>");
                        cadenaSalida.append(" </table>");




                }else if  (codTipCombo.equals("llenarComboForAfterUpdate"))
                {
                        //int codOee =Integer.parseInt(request.getParameter("codOee"));
                        //int idOge =Integer.parseInt(request.getParameter("idOge"));
                        int codActividad =Integer.parseInt(request.getParameter("codActividad"));
                        int idOee =Integer.parseInt(request.getParameter("idOee"));
                        lista = supportFacade.getlistOEE(id);
                        form.setOEE(lista);
                          cadenaSalida.append("<table  width='100%' align='center' >");
                        cadenaSalida.append("   <tr> ");
                        cadenaSalida.append("       <td width='50%'align='right'>");
                        cadenaSalida.append("           OEE &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                        cadenaSalida.append("       </td>");
                        cadenaSalida.append("       <td >");


                        cadenaSalida.append("           <select  name='codObjEsp' id='codOee' onchange='buscarComboActividades()' >");
                        cadenaSalida.append("               <option value='-1'>[--Seleccionar Obj Especifico--]</option>");
                          // JOptionPane.showMessageDialog(null, "id "+id);
                                                                Iterator it = lista.iterator();
                                                                while (it.hasNext()) {
                                                                        vo = (ProgEstrVO) it.next();
                                                                        if(vo.getCOD_OEE()!=idOee)
                                                                            cadenaSalida.append("<option value='"+vo.getCOD_OEE()+"'>"+vo.getDESC_OEE()+"</option>");
                                                                        else
                                                                            cadenaSalida.append("<option selected value='"+vo.getCOD_OEE()+"'>"+vo.getDESC_OEE()+"</option>");
                                                                }
                        cadenaSalida.append("           </select>");

                        cadenaSalida.append("         </td>");
                        cadenaSalida.append("   </tr>");


                        cadenaSalida.append("   <tr>");
                        cadenaSalida.append("       <td align='right'>");
                        cadenaSalida.append("           Actividades &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                        cadenaSalida.append("       </td>");

                        lista = supportFacade.getlistActividades(idOee);

                      //  cadenaSalida.append("<div id=comboHijo>");
                        cadenaSalida.append("       <td >");
                        cadenaSalida.append("           <select  name='codActividad' id='codActividad' >");
                        cadenaSalida.append("               <option value='-1'>[--Seleccionar Actividades--]</option>");
                                                             it = lista.iterator();
                                                             while (it.hasNext())
                                                             {
                                                                 vo = (ProgEstrVO) it.next();
                                                                 if(vo.getCOD_ACTIVIDAD()!=codActividad)
                                                                    cadenaSalida.append("<option value='"+vo.getCOD_ACTIVIDAD()+"'>"+vo.getDESC_ACTIVIDA()+"</option>");
                                                                 else
                                                                    cadenaSalida.append("<option selected value='"+vo.getCOD_ACTIVIDAD()+"'>"+vo.getDESC_ACTIVIDA()+"</option>");

                                                             }


                        cadenaSalida.append("           </select>");
                        cadenaSalida.append("       </td>");
                        cadenaSalida.append("   </tr>");
                        cadenaSalida.append(" </table>");
                }
                
                    // JOptionPane.showMessageDialog(null, form.getOEE().size());

            } catch (Exception e) {
                  cadenaSalida.append("error : "+e.toString());
            }
            out.print(cadenaSalida);

%>